/***************************************************************************
 *   Copyright (C) 2007 by Ivan Vasić                    *
 *   ivasic@gmail.com                     *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef TORRENTMANAGER_H
#define TORRENTMANAGER_H

#include <QObject>
#include <QMap>
#include "requesthandler.h"
#include "sha1hash.h"

class Request;
class AnnounceRequest;
class Torrent;

/**
 * @author Ivan Vasić <ivasic@gmail.com>
*/

class TorrentManager : public QObject, public RequestHandler
{
		Q_OBJECT

	public:
		TorrentManager(QObject *parent = 0);
		~TorrentManager();

		void handleRequest(Request* request);
		void handleAnnounceRequest(AnnounceRequest* announce);
		
		/**
		 * @brief Proverava da li je torrent registrovan.
		 * @param infohash SHA1Hash metainfo fajla.
		 */
		bool torrentRegistered(const SHA1Hash& infohash) const;
		
		/**
		 * @brief Registruje torrent na nas tracker.
		 * @param metainfo Niz bajtova metainfo fajla (torrent file sadrzaj)
		 * @param torrentName Naziv sadrzaja (ime torrenta ili kako god)
		 * @param description Opis sadrzaja
		 * @param size Velicina sadrzaja u bajtovima. (ne metainfo fajla vec download sadrzaja)
		 */
		void registerTorrent(const QByteArray& metainfo, const QString& torrentName, const QString& description);
};

#endif
